#pragma once
#include <d3d10_1.h>
#include "UserTypes.h"

using namespace System;
using namespace Reign::Core;
namespace I32 = Reign::Core::MathI32;

namespace Reign
{namespace Video
{namespace D3D10
{
	public ref class Caps
	{
		private: bool d3d10_1;
		public: property bool D3D10_1 {bool get(); internal: void set(bool value);}

		private: ShaderVersions maxShaderVersion;
		public: property ShaderVersions MaxShaderVersion {ShaderVersions get(); internal: void set(ShaderVersions value);}
	};

	public ref class Video : Disposable, VideoI
	{
		#pragma region Properties
		private: Window^ window;
		internal: I32::Vector2 lastWindowFrameSize;
		internal: int currentVertexResourceCount, currentPixelResourceCount;
		internal: ID3D10ShaderResourceView **currentVertexResources, **currentPixelResources;
		private: IDXGISwapChain* swapChain;
		private: ID3D10RenderTargetView* renderTarget;
		private: ID3D10DepthStencilView* depthStencil;
		private: ID3D10Texture2D* depthTexture;
		internal: ID3D10RenderTargetView* currentRenderTarget;
		internal: ID3D10DepthStencilView* currentDepthStencil;
		private: int vSync;

		private: ID3D10Device* device;
		internal: property ID3D10Device* Device {ID3D10Device* get();}

		private: Reign::Video::D3D10::Caps^ caps;
		public: property Reign::Video::D3D10::Caps^ Caps {Reign::Video::D3D10::Caps^ get(); private: void set(Reign::Video::D3D10::Caps^ value);}
		#pragma endregion
		
		#pragma region Constructors
		public: Video(DisposableI^ parent, Window^ window, bool vSync);
		public: Video(DisposableI^ parent, IntPtr handle, int width, int height, bool fullscreen, bool vSync);
		private: void init(DisposableI^ parent, IntPtr handle, int width, int height, bool fullscreen, bool vSync);
		private: void createViews(int width, int height);
		public: ~Video();
		private: void null();
		#pragma endregion

		#pragma region Methods
		public: virtual void Update();
		public: virtual void EnableRenderTarget();
		public: virtual void EnableRenderTarget(DepthStencilI^ depthStencil);
		public: virtual void DisableRenderTarget();
		public: virtual void Clear(float r, float g, float b, float a);
		public: virtual void ClearColor(float r, float g, float b, float a);
		public: virtual void ClearDepthStencil();
		public: virtual void Present();
		internal: void removeActiveResource(ID3D10ShaderResourceView* shaderResource);
		internal: static DXGI_FORMAT surfaceFormat(SurfaceFormats surfaceFormat);
		#pragma endregion
	};
}
}
}